package com.i2works.smartluolong.api.controller.carousel;

import java.util.ArrayList;
import java.util.List;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.i2works.smartluolong.api.utils.BaseModule;
import com.i2works.smartluolong.utils.entity.R;
import com.i2works.smartluolong.utils.entity.Result;
import com.i2works.smartluolong.utils.exception.ServiceException;
import com.i2works.smartluolong.web.entity.carousel.CarouselDO;
import com.i2works.smartluolong.web.entity.carousel.CarouselQuery;
import com.i2works.smartluolong.web.service.carousel.ICarouselService;

/**
 * 轮播图控制器
 *
 * @author Liu Yapeng
 * @date 2018/1/15 14:44
 */

@RestController
@RequestMapping("/carousel")
public class CarouselController extends BaseModule{
	
	private final ICarouselService carouselService;
	
	public CarouselController(ICarouselService carouselService) {
		  this.carouselService=carouselService;
	  }
	
	 @PostMapping("/index")
	 @ResponseBody
	    public Result index() {
	   
	    		
	       /**
	        * app轮播图接口
	        * */
	      
	    	CarouselQuery query=new CarouselQuery();
	    	query.setStatus(1);
	    	query.setType(2);//1.pc 2.app
	      	List<CarouselDO> carouselList=new ArrayList<CarouselDO>();
	      	Integer count=0;
	     	try {
	     	count=	carouselService.queryCount(query);
	    	carouselList=carouselService.queryList(query);
			} catch (ServiceException e) {
				e.printStackTrace();
			}
	    	
	        return  R.success(carouselList,count);
	    }


}
